package com.wyzz.hr.action;

import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.apache.axis.utils.StringUtils;
import org.apache.struts2.ServletActionContext;

import com.wyzz.hr.base.wf.overtimerequest.OrWfApproverAction;
import com.wyzz.hr.bo.IOvertimerequestBo;
import com.wyzz.hr.pojo.Employee;
import com.wyzz.hr.util.Pager;
import com.wyzz.hr.vo.ExaminSearchBean;
import com.wyzz.hr.vo.OvertimeFormBean;

public class DeptOvertimeSearchAction extends OrWfApproverAction {

	public DeptOvertimeSearchAction() {
	}

	public String execute() throws Exception {
		initOTLists();
		srcAction = "deptOverTimeSearch";
		actionSrc = "deptOvertimeSearch.action";
		Employee currentEmp = getCurrentEmp();
		if (page == null) {
			page = new Pager();
			page.setOrder("");
		} else if (page.getOrder().trim().length() == 0)
			page.setOrder("");
		if (es_Bean == null)
			es_Bean = new ExaminSearchBean();
		IOvertimerequestBo or_Bo = (IOvertimerequestBo) getBean("overtimerequestBO");
		or_Bo.approverMgrSearch(es_Bean, currentEmp, page);
		if (!StringUtils.isEmpty(infoMeg))
			addSuccessInfo(infoMeg);
		return "success";
	}

	public String deptOtApproveOrReject() throws Exception {
		String Ids[] = ServletActionContext.getRequest().getParameterValues(
				"changIds");
		String auth = checkActionAuth("deptOvertimeSearch", "execute");
		String operate = approveOper;
		if ("ALL".equals(auth))
			operate = (new StringBuilder()).append("gm-").append(operate)
					.toString();
		if ("SUB".equals(auth))
			operate = (new StringBuilder()).append("mgr-").append(operate)
					.toString();
		return wfObjOpBatch(operate, of_Bean, Ids);
	}

	public String deptOtApproveOrRejectWithModify() throws Exception {
		if (of_Bean == null)
			return "error";
		String auth = checkActionAuth("deptOvertimeSearch", "execute");
		String operate = "approve".equals(approveOper) ? "modify" : "reject";
		if ("ALL".equals(auth))
			operate = (new StringBuilder()).append("gm-").append(operate)
					.toString();
		if ("SUB".equals(auth))
			operate = (new StringBuilder()).append("mgr-").append(operate)
					.toString();
		return wfObjOpSingle(operate, of_Bean, orIdUp);
	}

	public void validate() {
		validateDate(es_Bean);
		validateOTStatus(es_Bean);
	}

	/**
	 * @deprecated Method get24Point is deprecated
	 */

	public String get24Point(Date date) {
		if (date == null)
			date = new Date();
		String result = null;
		SimpleDateFormat format = new SimpleDateFormat("HH:mm");
		if ("00:00".equals(format.format(date)))
			result = "24:00";
		else
			result = format.format(date);
		return result;
	}

	public ExaminSearchBean getEs_Bean() {
		return es_Bean;
	}

	public void setEs_Bean(ExaminSearchBean es_Bean) {
		this.es_Bean = es_Bean;
	}

	public Pager getPage() {
		return page;
	}

	public void setPage(Pager page) {
		this.page = page;
	}

	public String getActionSrc() {
		return actionSrc;
	}

	public void setActionSrc(String actionSrc) {
		this.actionSrc = actionSrc;
	}

	public int getGmanager() {
		return gmanager;
	}

	public void setGmanager(int gmanager) {
		this.gmanager = gmanager;
	}

	public String getSrcAction() {
		return srcAction;
	}

	public void setSrcAction(String srcAction) {
		this.srcAction = srcAction;
	}

	public String getApproveOper() {
		return approveOper;
	}

	public void setApproveOper(String approveOper) {
		this.approveOper = approveOper;
	}

	public String getRejectLog() {
		return rejectLog;
	}

	public void setRejectLog(String rejectLog) {
		this.rejectLog = rejectLog;
	}

	public String getInfoMeg() {
		return infoMeg;
	}

	public void setInfoMeg(String infoMeg) {
		this.infoMeg = infoMeg;
	}

	public String getIsTiaoxiu() {
		return isTiaoxiu;
	}

	public void setIsTiaoxiu(String isTiaoxiu) {
		this.isTiaoxiu = isTiaoxiu;
	}

	public String getOrIdUp() {
		return orIdUp;
	}

	public void setOrIdUp(String orIdUp) {
		this.orIdUp = orIdUp;
	}

	public OvertimeFormBean getOf_Bean() {
		return of_Bean;
	}

	public void setOf_Bean(OvertimeFormBean of_Bean) {
		this.of_Bean = of_Bean;
	}

	public String getTiaoXiuTime() {
		return tiaoXiuTime;
	}

	public void setTiaoXiuTime(String tiaoXiuTime) {
		this.tiaoXiuTime = tiaoXiuTime;
	}

	private static final long serialVersionUID = 1L;
	private ExaminSearchBean es_Bean;
	private Pager page;
	private String actionSrc;
	private int gmanager;
	private String srcAction;
	private String approveOper;
	private String rejectLog;
	private String orIdUp;
	private OvertimeFormBean of_Bean;
	private String infoMeg;
	private String isTiaoxiu;
	private String tiaoXiuTime;
}
